import api from './request.js'
import baseconfig from '@/config.js'

export function login(parms) {
	return api.post('/nl/loginUser', parms)
}
// 微信小程序登录
export function wxmplogin(params) {
	return api.post('/nl/loginByWxcode', params)
}
/*
 * 置顶套餐
 */
export function getSysTopInfo() {
	return api.get('/nl/getSysTopInfo')
}
/*
 *
 */
export function getarea() {
	return api.get('/wuser/area.json')
}


//#region 品牌车系

/*
 *获取品牌
 */
export function getBrandInfo() {
	return api.get('/nl/getBrandInfo', '')
}

/*
 *获取品牌车系
 */
export function getSubBrandInfoByBrand(parms) {
	return api.get('/nl/getSubBrandInfoByBrand', parms)
}

/*
 *获取品牌车系车型
 */
export function getCarTypeInfoById(parms) {
	return api.get('/nl/getCarTypeInfoById', parms)
}
//#endregion

//#regin
/*
 *查询指定用户的信息
 *
 **/
export async function queryUserInfo(uid) {

	const { code, data, msg } = await api.post('/nl/queryUserInfo', { id: uid }) 
	var keys = ["upload", "pyq", "need"]
	keys.forEach(arr => {
		if (!data[arr]) {
			data[arr] = 0
		}
	})
	return new Promise((resolve, reject) => {
		resolve({ code, data, msg })
	})
}
/*

*/
//#endregion

// #region 车源
//上传车源图片
export function uploadCarImg(filedata, info) {
	return api.uploadFile('/user/uploadCarImg', filedata, info)
}
//发布车源
export function uploadCarInfo(parm) {
	return api.post('/user/uploadCarInfo', parm)
}
/*
 * 删除车源图片
 */
export function removeCarImg(parm) {
	return api.post('/user/removeCarImg', parm)
}
/*
 * 更新车源
 */
export function updateCarInfo(parm) {
	return api.post('/user/updateCarInfo', parm)
}

/*
 *所有车源
 */
export function queryAllUploadCarInfo(parms) {
	return api.get('/nl/queryAllUploadCarInfo', parms)
}

/*
 *车源详情
 */
export function queryCarInfo(parms) {
	return api.get('/nl/queryCarInfo', parms)
}

/*
 *获取登录用户的车源
 */
export function queryUserCarInfo(parm) {
	return api.post('/user/queryUserCarInfo', parm)
}
/*
 *设置是否在售  istop 是否已下架(1 下架,0 在售), id 车信息的id
 */
export function setUserCarIsEnd(parm) {
	return api.post('/user/setUserCarIsEnd ', parm)
}
/*
 *设置是否置顶  isend 是否已下架(1 下架,0 在售), id 车信息的id
 */
export function setUserCarIsTop(parm) {
	return api.post('/user/setUserCarIsTop ', parm)
}


//#endregion

//#region  求购

/*
 *发布求购
 */
export function uploadUserNeedBuyInfo(parm) {
	return api.post('/user/uploadUserNeedBuyInfo', parm)
}

/*
 *全体求购列表
 */
export function getAllNeedBuyInfo(parm) {
	return api.post('/nl/getAllNeedBuyInfo', parm)
}

/*
 *求购详情
 */
export function queryNeedBuyInfo(id) {
	return api.post('/nl/queryNeedBuyInfo', { id: id })
}

/*
 *登录用户的求购列表
 */
export function getUserNeedBuyInfo(params) {
	return api.post('/user/getUserNeedBuyInfo', params)
}
/*
 * 设置求购取消状态
 */
export function cancelNeedBuyInfo(parm) {
	return api.post('/user/cancelNeedBuyInfo', parm)
}
/*
 * 更新求购
 */
export function updateUserNeedBuyInfo(parm) {
	return api.post('/user/updateUserNeedBuyInfo', parm)
}
//#endregion

//#region 朋友圈

/*
 *朋友圈分页
 */
export function queryAllPyqInfo(parms) {
	return api.get('/nl/queryAllPyqInfo', parms)
}
export function queryPyqInfo(pyqid) {
	return api.get('/nl/queryPyqInfo', { id: pyqid })
}

/*
 *发表评论
 */
export function pyqComment(parm) {
	return api.post('/user/pyqComment', parm)
}

/*
 *查询朋友圈的评论
 */
export function queryPyqComment(parm) {
	return api.post('/nl/queryPyqComment', parm)
}
/*
 *查询登录用户朋友圈
 */
export function querySelfPyqInfo() {
	return api.get('/user/querySelfPyqInfo')
}
//#endregion


/*
 *更新用户昵称头像
 */
export function updateUserInfo(name, filedata) {
	if (filedata) {
		return api.postfile('/user/updateUserInfo', filedata, { name: name })
	} else {
		return api.get('/user/updateUserInfo', { name: name })
	}
}
/*
 *获取登录信息
 */
export function getUserInfo() {
	return api.get('/user/getUserInfo')
}
export function querySelfUploadCount() {
	return api.get('/user/querySelfUploadCount')
}



//#region 认证商家
// 上传认证图
export function uploadBusinessImg(filedata, type, infoid) {
	return api.postfile('/user/uploadBusinessImg', filedata, {
		imgtype: type,
		infoid: infoid,
	})
}
// 认证商家
export function uploadBusinessInfo(parms) {
	return api.post('/user/uploadBusinessInfo', parms)
}
// 查询认证信息
export function queryUserBusinessInfo() {
	return api.post('/user/queryUserBusinessInfo')
}
// 清空认证图片
export function removeAllBusiImg() {
	return api.get('/user/removeAllBusiImg')
}
//#endregion

//#region 群系统

/*
 *查询所有群列表
 */
export function getChatGroupList(parm) {
	return api.post('/nl/getChatGroupList', parm)
}

/*
 *群名额套餐 
 */
export function getSysGroupCountInfo() {
	return api.get('/nl/getSysGroupCountInfo')
}
/*
 *查询自己已加群
 */
export function getSelfGroupList() {
	return api.get('/user/getSelfGroupList')
}
/*
 *查询自己加群资格 
 */
export function getSelfGroupCountInfo() {
	return api.get('/user/getSelfGroupCountInfo')
}
/*
 *申请加群 
 */
export function addToGroup(parm) {
	return api.post('/user/addToGroup', parm)
}
//#endregion

//#regin 个人店铺
/*
 *同行求购
 */
export function queryUserNeedBuyInfoByUid(parm) {
	return api.post('/nl/queryUserNeedBuyInfoByUid', parm)
}
/*
 *同行车源
 */
export function queryUserCarInfoByUid(parm) {
	return api.post('/nl/queryUserCarInfoByUid', parm)
}
/*
 *同行车源
 */
export function queryUserPyqByUid(parm) {
	return api.post('/nl/queryUserPyqByUid', parm)
}

//#endregin

export function searchAllByVal(parm) {
	return api.post('/nl/searchAllByVal', parm)
}

//#regin 支付
export function buyTop(parm) {
	return api.post('/user/buyTop', parm)
}
export function buyGroupCount(parm) {
	return api.post('/user/buyGroupCount', parm)
}
//#endregin


export function getBannerImgs() {
	return api.get('/nl/getBannerImgs')
}
//#regin 会员
export function getVipBuy() {
	return api.get('/nl/getVipBuy')
}
export function buyVip(parm) {
	return api.post('/user/buyVip', parm)
}
//#endregin
export function getUnlimitedQRCode(parm) {
	return api.post('/nl/getUnlimitedQRCode', parm)
}
/*
 * 登录用户VIP权益记录
 */
export function getVipItemCount() {
	return api.get('/user/getVipItemCount')
}
/*
 * 朋友圈上传次数排行榜
 */
export function loadUserPyqCountTop() {
	return api.get('/nl/loadUserPyqCountTop')
}

/*
 * 同行列表
 */
export function getAllSames(parm) {
	return api.post('/user/getAllSames', parm)
}
export function getSamePlaceUsers(parm){
	
		return api.post('/user/getSamePlaceUsers', parm)
}
/*
 * 担保按钮
 */
export function getDanbaoImg() {
	return api.get("/nl/getDanbaoImg")
}
/*
 * 自定义菜单
 */
export function getCustMenu() {
	return api.get("/nl/getCustMenu")
}
/*
* 系统配置
*/
export function geSysCfgInfo(){
	return api.get("/nl/geSysCfgInfo")
}